package com.xframe.domain.e3sp.basedata;

import com.xframe.domain.BaseModel;
import com.xframe.xdal.core.annotation.*;
import com.xframe.xdal.core.constant.AutoFillType;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @Description: 供应商类别
 * @ClassName: com.xframe.domain.e3sp.basedata.Supplier
 * @Author: lmx
 * @CreateTime: 2024/01/04
 **/
@Data
@Accessors(chain=true)
@XTable(value = "p_t02_supplier", label = "供应商")
@XSelectItem(keyName = "supplierId",codeName = "supplierName",textName = "supplierName")
@XBelongsTo(typeName = "com.xframe.domain.e3sp.basedata.SupplierType",foreignKey = "supplierTypeId", targetKey = "supplierTypeId",as = "refSupplierType")
public class Supplier extends BaseModel {
    /**
     * 供应商ID
     */
    @AutoFill(AutoFillType.Snowflake)
    @XColumn(name = "supplier_id", primaryKeyFlag = true,desc = "供应商ID")
    private Long supplierId;

    /**
     * 供应商编码
     */
    @XQueryCondition
    @XColumn(name = "supplier_code", uniqueFlag = true,desc = "供应商编码",length = 20)
    @XGridTableRef
    private String supplierCode;

    /**
     * 供应商类别ID
     */
    @XQueryCondition
    @XColumn(name = "supplier_type_id", desc = "供应商类别ID",nullFlag = true)
    private Long supplierTypeId;

    /**
     * 供应商全称
     */
    @XQueryCondition
    @XColumn(name = "supplier_full_name",desc = "供应商全称",length = 200)
    @XGridTableRef
    private String supplierFullName;

    /**
     * 供应商简称
     */
    @XQueryCondition
    @XColumn(name = "supplier_name",desc = "供应商全称",length = 200,nullFlag = true)
    @XGridTableRef
    private String supplierName;

    /**
     * 联系人
     */
    @XQueryCondition
    @XColumn(name = "contacts",desc = "联系人",length = 200,nullFlag = true)
    @XGridTableRef
    private String contacts;

    /**
     * 联系电话
     */
    @XQueryCondition
    @XColumn(name = "telephone",desc = "联系电话",length = 200,nullFlag = true)
    @XGridTableRef
    private String telephone;

    /**
     * 传真
     */
    @XQueryCondition
    @XColumn(name = "fax",desc = "传真",length = 200,nullFlag = true)
    @XGridTableRef
    private String fax;

    /**
     * 备件来源类别 0 = 国产 1 = 进口
     */
    @XQueryCondition
    @XColumn(name = "part_sou_type",desc = "备件来源类别",length = 11)
    @XGridTableRef
    private Long partSouType;

    /**
     * 备件来源 0 = 自制  1 = 外购
     */
    @XQueryCondition
    @XColumn(name = "part_sou",desc = "备件来源",length = 11)
    @XGridTableRef
    private Long partSou;

    /**
     * SAP状态
     */
    @XQueryCondition
    @XColumn(name = "sap_status",desc = "SAP状态",length = 10)
    @XGridTableRef
    private String sapStatus;

    /**
     * 获得采购单状态
     */
    public Integer getProcBillType()
    {
            /*
             * "国产件", "1" "进口件", "2" "自制件", "3"
            供应商是国产 自制属性，类型为：自制件
            供应商是国产  外购     类型为：国产件
            供应商是进口  外购     类型为：进口件
            */
        if (this.partSou.equals("0") && this.partSouType.equals("0"))
        {
            return 3;
        }
        else if (this.partSou.equals("1") && this.partSouType.equals("0"))
        {
            return 1;
        }
        else
        {
            return 2;
        }
    }

    private SupplierType refSupplierType;

}
